package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.OmsOrder;
import com.itheima.domain.OmsOrderSetting;
import com.itheima.mapper.OmsOrderMapper;
import com.itheima.mapper.OmsOrderSettingMapper;
import com.itheima.service.db.OrderSettingService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class OrderSettingServiceImpl extends ServiceImpl<OmsOrderSettingMapper, OmsOrderSetting> implements OrderSettingService {

    @Autowired
    OmsOrderSettingMapper orderSettingMapper;

    @Autowired
    OmsOrderMapper orderMapper;

    @Override
    public void updateSetting(long id, OmsOrderSetting orderSetting) {
        //订单属性的完善
        OmsOrder order = orderMapper.selectById(id);
        if(order != null){
            order.setAutoConfirmDay(orderSetting.getConfirmOvertime());
            orderMapper.updateById(order);
        }
        //添加配置到配置表中
        orderSettingMapper.updateById(orderSetting);
    }

    @Override
    public OmsOrderSetting getSetting(long id) {
        OmsOrderSetting orderSetting = orderSettingMapper.selectById(id);
        return orderSetting;
    }
}
